/*
 * Copyright (c) 2006, 2023, webrx.cn All rights reserved.
 *
 */
package cn.ex;

/**
 * <p>Project: jse2302 - Ex1
 * <p>Powered by webrx On 2023-06-15 11:05:46
 * <p>Created by IntelliJ IDEA
 *
 * @author  webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */
public class Ex1 {
    public static void main(String[] args) {
        System.out.println(pf(3));

        //20 20 实参
        int ok = sum(10, 20);
        System.out.println(ok);

        //
        System.out.println(sum(1, 2));

        int sss = sum(new int[]{2});
        System.out.println(sss);
        System.out.println(sum(new int[]{1, 2, 3, 4, 5}));
        System.out.println(sum(null));
        System.out.println(sumok());
        System.out.println(sumok(1,2,3));
        System.out.println(sumok(1,2,3,10,20,100));

        //print("ok");

        Ex1 ex = new Ex1();
        //ex.print("hello world",31);
        //ex.print("hello world",32);
        for (int i = 0; i < 8; i++) {
            ex.print("hello world",30+i);
        }
    }

    void print(String str,int c){
        System.out.println(String.format("\033[%dm%s\033[0m",c,str));
    }


    static int pf(int i) {
        return i * i;
    }

    // 形参
    static int sum(int a, int b) {
        return a + b;
    }

    static int sum(int a, int b, int c) {
        int t = a + b + c;
        return t;
    }

    static int sum(int[] ns) {
        int t = 0;
        if (ns != null) {
            for (int i : ns) {
                t += i;
            }
        }
        return t;
    }

    static int sumok(int... ns) {
        return sum(ns);
    }

}
